﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using GameEngine.Clients.Silverlight.View;
using GameEngine.View.Components;

namespace MySettlers.View.Components
{
    public partial class GameMainMenu : UserControl, IMenuView<string>
    {
        public event OnButtonClickHandler<string> OnExternalActionButtonClick;
        public const string BACKBUTTON = "BACKBUTTON";
        public const string NEWBUTTON = "NEWBUTTON";
        public const string LOADBUTTON = "LOADBUTTON";
        public const string IMPORTBUTTON = "IMPORTBUTTON";

        public GameMainMenu()
        {
            InitializeComponent();
            NewButton.Tag = NEWBUTTON;
            LoadButton.Tag = LOADBUTTON;
            ImportButton.Tag = IMPORTBUTTON;
            BackButton.Tag = BACKBUTTON;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button b = (Button)sender;
            OnExternalActionButtonClick(b.Tag as string);
        }

        internal void addSavedGames(List<SavedGameFile> files)
        {
            SavedGamesComboBox.Items.Clear();
            foreach (SavedGameFile file in files)
                SavedGamesComboBox.Items.Add(file);
            if (SavedGamesComboBox.Items.Count > 0)
                SavedGamesComboBox.SelectedItem = SavedGamesComboBox.Items[0];
        }

        public SavedGameFile getSelectedGame()
        {
            return (SavedGameFile)SavedGamesComboBox.SelectedItem;
        }
    }
}
